<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <title>高级搜索 ${(word)!} - PublicCMS</title>
        <meta name="keywords" content="高级搜索,分面搜索,智能搜索"/>
        <meta name="description" content="高级搜索  ${word!}"/>
        <@_includePlace path="/8ddab9ba-a8aa-4745-86c6-66bf1c2c976c.html"/> <#-- header -->
    </head>
    <body>
        <@_includePlace path="/c32a4f4a-ff5d-49cf-bb59-5d9784539174.html"/> <#-- 导航 -->
        <div class="banner-l3 position-relative d-flex align-items-center justify-content-center" style="background:#22407c url(${site.sitePath}assets/img/banner-l3-bg-1.png) 50% 50% no-repeat;">
            <div class="container text-center position-relative py-3 py-md-4 text-white">
                <div class="breadcrumbs fs-7 text-white d-inline-flex align-items-center text-opacity-50">
                    <a href="${site.sitePath}">首页</a>  &gt; <a href="${siteAttribute.searchPath!}">搜索</a>
                </div>
            </div>
        </div>

        <div class="container">
            <div class="row">
                <div class="col-12 mt-5">
                    <form action="facet.html" method="get" name="search">
                        <div class="input-group mb-3" style="border-radius: 10px;padding: 10px;background-color: rgba(0,0,0,.05);">
                            <input type="search" class="form-control fs-3" name="word" placeholder="您想搜索什么？" value="${(word)!}">
                            <button class="btn btn-primary flex-shrink-0 px-2 px-md-5 fs-4" type="submit">立即搜索</button>
                        </div>
                        <div class="form-check form-switch d-inline-block">
                          <input class="form-check-input" type="checkbox" name="phrase" id="phrase" value="true"<#if phrase?has_content && 'true'=phrase> checked="checked"</#if> onclick="$('form[name=search]').submit();">
                          <label class="form-check-label" for="phrase">精确搜索</label>
                        </div>
                        <#if categoryId?has_content><input type="hidden" name="categoryId" value="${categoryId!}"/></#if>
                        <#if modelId?has_content><input type="hidden" name="modelId" value="${modelId!}"/></#if>
                    <#if dictionaryValues?has_content>
                        <#list dictionaryValues as d>
                            <input type="hidden" name="dictionaryValues" value="${d}"/>
                        </#list>
                    </#if>
                    <#if tagIds?has_content>
                        <#list tagIds as t>
                            <input type="hidden" name="tagIds" value="${t}"/>
                        </#list>
                    </#if>
                    </form>

<#if word?has_content || tagIds?has_content || dictionaryValues?has_content>
    <@_facetSearch word=word tagId=tagIds categoryId=categoryId dictionaryValues=dictionaryValues modelId=modelId phrase=phrase highlight=true  pageIndex=pageIndex pageSize=10>
            <#if page.totalCount gt 0>
                         <@import path="/ftl/tools.ftl" namespace="t"/>

                        <div class="my-4">
                            <#if (page.facetMap.categoryId)?has_content>
                            <div class="d-flex align-items-center my-3">
                                <b class="flex-shrink-0">分类：</b>
                                    <#list page.facetMap.categoryId?keys as k><@t.merge 'categoryIds' k/></#list>
                                    <@_category ids=(t.categoryIds)!><#assign categoryMap=map/></@_category>
                                <ul class="nav nav-pills nav-facet">
                                     <#list page.facetMap.categoryId?keys as k>
                                        <#if k?is_first && categoryMap[k]?has_content><#assign firstCategory=categoryMap[k]/></#if>
                                        <li class="nav-item">
                                            <a <#if (k=categoryId!'')>class="nav-link active" href="javascript:search('categoryId','');"<#else>class="nav-link" href="javascript:search('categoryId','${k}');"</#if>>${(categoryMap[k].name)!}(${(page.facetMap.categoryId[k])!})</a>
                                        </li>
                                    </#list>
                                </ul>
                            </div>
                            </#if>

                            <#if (page.facetMap.modelId)?has_content>
                            <div class="d-flex align-items-center my-3">
                                <b class="flex-shrink-0">模型：</b>
                                    <#list page.facetMap.modelId?keys as k><@t.merge 'modelIds' k/></#list>
                                    <@_model ids=(t.modelIds)!><#assign modelMap=map!/></@_model>
                                <ul class="nav nav-pills nav-facet">
                                    <#list page.facetMap.modelId?keys as k>
                                        <#if k?is_first><#assign firstModel=modelMap[k]/></#if>
                                    <li class="nav-item">
                                        <a <#if (k=modelId!'')>class="nav-link active" href="javascript:search('modelId','');"<#else>class="nav-link" href="javascript:search('modelId','${k}');"</#if>>${(modelMap[k].name)!}(${(page.facetMap.modelId[k])!})</a>
                                    </li>
                                    </#list>
                                </ul>
                            </div>
                            </#if>

                            <@_tag ids=tagIds>
                                <#if map?has_content>
                                    <div class="d-flex align-items-center my-3">
                                        <b class="flex-shrink-0">标签：</b>
                                        <ul class="nav nav-pills nav-facet">
                                            <#list map?keys as k>
                                            <li class="nav-item">
                                                <a class="nav-link active" href="javascript:search('tagIds','');">${map[k].name}</a>
                                            </li>
                                            </#list>
                                        </ul>
                                    </div>
                                </#if>
                            </@_tag>

                        <#macro dictionarySearch extendList>
                            <#list extendList as extend>
                                <div class="d-flex align-items-center my-3">
                                    <@_dictionary id=extend.dictionaryId>
                                    <b class="flex-shrink-0">${object.name}：</b>
                                    <ul class="nav nav-pills nav-facet">
                                        <li class="nav-item">
                                            <a  class="nav-link${(!dictionaryValues?has_content)?then(' active','')?no_esc}" href="javascript:search('dictionaryValues','');">全部</a>
                                            </li>
                                        <@_dictionaryDataList dictionaryId=object.id.id>
                                            <#list list as d>
                                            <li class="nav-item">
                                                <a class="nav-link<#if (dictionaryValues?has_content && dictionaryValues?seq_contains(extend.id.code+'_'+d.id.value))> active</#if>"  href="javascript:search('dictionaryValues','${extend.id.code}_${d.id.value!}');">${d.text}</a>
                                            </li>
                                            </#list>
                                        </@_dictionaryDataList>
                                    </ul>
                                    </@_dictionary>
                                </div>
                            </#list>
                        </#macro>

                        <#if (firstCategory.extendId)?has_content>
                            <@_sysExtendFieldList extendId=firstCategory.extendId inputType='dictionary' searchable=true>
                                <@dictionarySearch list/>
                            </@_sysExtendFieldList>
                        </#if>
                        <#if (firstModel.extendList)?has_content>
                            <@dictionarySearch firstModel.extendList/>
                        </#if>
                    </div>

                    <header class="tab-header fs-5 mt-5">
                        <b class="pb-2">搜索结果</b>
                    </header>
                    <div class="article-list">
                        <#list page.list as a>
                        <a href="${a.url}" class="d-block">
                            <div class="card flex-md-row align-items-start">
                                <div class="card-body py-3 py-md-0 px-0 px-md-3">
                                    <h5 class="text-body">${a.title?no_esc}</h5>
                                    <p class="fs-7 text-secondary">${(a.description?no_esc)!}</p>
                                    <footer class="fs-8 text-secondary text-opacity-50 d-flex align-items-center">
                                        <span class="me-4 d-inline-flex align-items-center"><img src="${site.sitePath}assets/img/icon-calendar.svg">${a.publishDate?date}</span>
                                        <span class="me-4 d-inline-flex align-items-center"><img src="${site.sitePath}assets/img/icon-view.svg">${a.clicks!}</span>
                                        <span class="me-4 d-inline-flex align-items-center"><img src="${site.sitePath}assets/img/icon-comment.svg">${a.comments!}</span>
                                    </footer>
                                </div>
                            </div>
                        </a>
                        </#list>
                    </div>
                    <ul class="pagination mt-5 overflow-auto pb-3">
                        <#assign url='./facet.html?word='+(word?url)!/>
                        <#if phrase?has_content>
                            <#assign url+='&phrase='+phrase?url/>
                        </#if>
                        <#if categoryId?has_content>
                            <#assign url+='&categoryId='+categoryId?url/>
                        </#if>
                        <#if modelId?has_content>
                            <#assign url+='&modelId='+modelId?url/>
                        </#if>
                        <#if dictionaryValues?has_content>
                            <#list dictionaryValues as d>
                                <#assign url+='&dictionaryValues='+d?url/>
                            </#list>
                        </#if>
                        <#if tagIds?has_content>
                            <#list tagIds as t>
                                <#assign url+='&tagIds='+t/>
                            </#list>
                        </#if>
                        <li class="page-item">
                            <a class="page-link" href="${getPage(url,page.prePage,'pageIndex')}" aria-label="Previous">
                                <span aria-hidden="true">«</span>
                            </a>
                        </li>
                        <#assign start=1/>
                        <#if (page.pageIndex-5) gt start>
                            <#assign start=page.pageIndex-4/>
                        </#if>
                        <#assign end=page.totalPage/>
                        <#if (page.pageIndex+5) lt end>
                            <#assign end=page.pageIndex+4/>
                        </#if>
                        <#list start..end as a>
                        <li class="page-item<#if a=page.pageIndex> active</#if>"><a class="page-link" href="${getPage(url,a,'pageIndex')}">${a}</a></li>
                        </#list>
                        <li class="page-item">
                            <a class="page-link" href="${getPage(url,page.nextPage,'pageIndex')}" aria-label="Next">
                                <span aria-hidden="true">»</span>
                            </a>
                        </li>
                    </ul>
        </#if>
     </@_facetSearch>
</#if>
                </div>
            </div>
        </div>

        <@_includePlace path="/7f8bacb5-30ca-4641-b66f-987d447b1a85.html"/> <#-- footer -->
        <script>
        function search(name,value){
            var $form = $('form[name=search]');
            var $input = $form.find('input[name='+name+']');
            if(0 == $input.length && value){
                $input = $('<input type="hidden"/>').attr('name',name).appendTo($form);
            }
            if(value){
                $input.val(value);
            }else{
                $input.remove();
            }
            $form.submit();
            return false;
        }
    </script>
    </body>
</html>